package work;

import java.util.Random;
import java.util.Scanner;

public class AppleGame {
    public static void main(String[] args) {
        test();
    }
    public static void test() {
        Scanner sc = new Scanner(System.in);
        int money = 10;
        String str1 = "苹果";
        String str2 = "木瓜";
        String str3 = "西瓜";
        String str4 = "香蕉";
        String str5 = "橙子";
        String str6 = "葡萄";
        while (true) {
            menu(money);
            int storage = money;
            System.out.println("请选择您选中的水果:");
            String choice = sc.next();
            if(choice.equals("Q")){
                System.out.println("退出游戏");
                System.exit(0);
            }
            System.out.println("请选择您要下注的金币数" + "(最多" + money +"金币)" );
            int betting = sc.nextInt();
            while(betting > money||betting < 0){
                System.out.println("您下注的金币数不合理,请重新下注:");
                betting = sc.nextInt();
            }
            System.out.println("幸运机开始运转----------Good Luck");
            int num = getRandom();
            String lucky = "null";
            switch (num) {
                case 1:
                    lucky = str1;break;
                case 2:
                    lucky = str2;break;
                case 3:
                    lucky = str3;break;
                case 4:
                    lucky = str4;break;
                case 5:
                    lucky = str5;break;
                case 6:
                    lucky = str6;
            }
            System.out.println("-----" + lucky + "-----");
            money -= betting;
            if (choice.equals(lucky)) {
                switch (num) {
                    case 1:
                        money += 2 * betting;
                        break;
                    case 2:
                        money += 5 * betting;
                        break;
                    case 3:
                        money += 10 * betting;
                        break;
                    case 4:
                        money += 20 * betting;
                        break;
                    case 5:
                        money += 50 * betting;
                        break;
                    case 6:
                        money += 100 * betting;
                }
                System.out.println("恭喜您,猜对了!,您赢了" + (money - storage + betting));
            } else {
                System.out.println("很遗憾,您猜错了,您损失了" + betting + "金币");
            }
            if(money == 0){
                System.out.println("您的筹码已经完了,退出游戏");
                break;
            }

        }

    }
    public static int getRandom(){
        Random random = new Random();
        int num = random.nextInt(6) + 1;
        return num;
    }



    public static void menu(int money) {
        System.out.println("澳门新葡京娱乐城8848,搏一搏,单车变摩托!");
        System.out.println("您当前的金币总计:" + "$" + money);
        System.out.println("欢迎进入游戏,新的一轮游戏马上开始!");
        System.out.println("猜中的物品和对应的奖励系数如下:");
        System.out.println("苹果" + "-----------" + "2");
        System.out.println("木瓜" + "-----------" + "5");
        System.out.println("西瓜" + "-----------" + "10");
        System.out.println("香蕉" + "-----------" + "20");
        System.out.println("橙子" + "-----------" + "50");
        System.out.println("葡萄" + "-----------" + "100");
        System.out.println("游戏结束,请按Q");
    }
}
